<?php defined('InShopNC') or exit('Access Invalid!');?>
<?php require('groupbuy_head.php');?>
<form id="search_form">
  <input name="act" type="hidden" value="show_groupbuy" />
  <input name="op" type="hidden" value="<?php echo $_GET['op'];?>" />
  <input id="groupbuy_area" name="groupbuy_area" type="hidden" value="<?php echo $_GET['groupbuy_area'];?>"/>
  <input id="groupbuy_class" name="groupbuy_class" type="hidden" value="<?php echo $_GET['groupbuy_class'];?>"/>
  <input id="groupbuy_price" name="groupbuy_price" type="hidden" value="<?php echo $_GET['groupbuy_price'];?>"/>
  <input id="groupbuy_order_key" name="groupbuy_order_key" type="hidden" value="<?php echo $_GET['groupbuy_order_key'];?>"/>
  <input id="groupbuy_order" name="groupbuy_order" type="hidden" value="<?php echo $_GET['groupbuy_order'];?>"/>
</form>
<div class="ncg-container wrapper">
    <div class="ncg-category" id="ncgCategory">
        <?php if(!empty($output['real_tree']) && is_array($output['real_tree'])) { ?>
        <h3><a href="<?php echo urlShop('show_groupbuy', 'groupbuy_list',array('isv'=>0));?>">线上团</a></h3>
        <ul>
            <?php foreach($output['real_tree'] as $real_tree) { ?>
            <li><a href="<?php echo urlShop('show_groupbuy','groupbuy_list',array('groupbuy_class'=>$real_tree['class_id']))?>"><?php echo $real_tree['class_name'];?></a></li>
            <?php } ?>
        </ul>
        <?php } ?>
        <?php if(!empty($output['virtual_tree']) && is_array($output['virtual_tree'])) { ?>
        <h3><a href="<?php echo urlShop('show_groupbuy', 'groupbuy_list',array('isv'=>1));?>">虚拟团</a></h3>
        <ul>
            <?php foreach($output['virtual_tree'] as $virtual_tree) { ?>
                <li><a href="<?php echo urlShop('show_groupbuy','groupbuy_list',array('groupbuy_class'=>$virtual_tree['class_id'],'isv'=>1))?>"><?php echo $virtual_tree['class_name'];?></a></li>
            <?php } ?>
        </ul>
        <?php } ?>
    </div>

    <div class="ncg-content">
        <div class="ncg-slides-banner">
            <ul id="fullScreenSlides" class="full-screen-slides">
                <li style="z-index: 900; display: none;"><a href="" target="_blank"><img src=""></a></li>
                <li style="display: list-item; z-index: 800;"><a href="" target="_blank"><img src=""></a></li>
            </ul>
            <ul class="full-screen-slides-pagination"><li class=""><a href="javascript:void(0)">1</a></li><li class="current"><a href="javascript:void(0)">2</a></li></ul>
        </div>

        <div class="group-list mt20">
            <div class="ncg-recommend-title">
                <h3>线上团购推荐</h3>
                <a href="<?php echo(urlShop('show_groupbuy','groupbuy_list',array('isv'=>0)));?>" class="more">查看更多</a></div>
            <ul>
                <?php if(!empty($output['rgroupbuy_list']) && is_array($output['rgroupbuy_list'])) { ?>
                 <?php foreach($output['rgroupbuy_list'] as $groupbuy) { ?>
                    <li class="online">
                        <div class="ncg-list-content"> <a title="<?php echo $groupbuy['groupbuy_name'];?>" href="<?php echo $groupbuy['groupbuy_url'];?>" class="pic-thumb" target="_blank"><img src="<?php echo gthumb($groupbuy['groupbuy_image'],'mid');?>" alt=""></a>
                            <h3 class="title"><a title="<?php echo $groupbuy['groupbuy_name'];?>" href="<?php echo $groupbuy['groupbuy_url'];?>" target="_blank"><?php echo $groupbuy['groupbuy_name'];?></a></h3>
                            <?php list($integer_part, $decimal_part) = explode('.', $groupbuy['groupbuy_price']);?>
                            <div class="item-prices"> <span class="price"><i><?php echo $lang['currency'];?></i><?php echo $integer_part;?><em>.<?php echo $decimal_part;?></em></span>
                                <div class="dock"><span class="limit-num"><?php echo $groupbuy['groupbuy_rebate'];?>&nbsp;<?php echo $lang['text_zhe'];?></span> <del class="orig-price"><?php echo $lang['currency'].$groupbuy['goods_price'];?></del></div>
                                <span class="sold-num"><em><?php echo $groupbuy['buy_quantity']+$groupbuy['virtual_quantity'];?></em><?php echo $lang['text_piece'];?><?php echo $lang['text_buy'];?></span><a href="<?php echo $groupbuy['groupbuy_url'];?>" target="_blank" class="buy-button">我要团</a></div>
                        </div>
                    </li>
                    <?php } ?>
                <?php } else { ?>
                    <div class="no-content"><?php echo $lang['no_groupbuy_info'];?></div>
                <?php } ?>
            </ul>
        </div>
        <div class="group-list mt30">
            <div class="ncg-recommend-title">
                <h3>虚拟团购推荐</h3>
                <a href="<?php echo(urlShop('show_groupbuy','groupbuy_list',array('isv'=>1)));?>" class="more">查看更多</a></div>
            <ul>
                <?php if(!empty($output['vgroupbuy_list']) && is_array($output['vgroupbuy_list'])) { ?>
                <?php foreach($output['vgroupbuy_list'] as $groupbuy) { ?>
                <li class="online">
                    <div class="ncg-list-content"> <a title="<?php echo $groupbuy['groupbuy_name'];?>" href="<?php echo $groupbuy['groupbuy_url'];?>" class="pic-thumb" target="_blank"><img src="<?php echo gthumb($groupbuy['groupbuy_image'],'mid');?>" alt=""></a>
                        <h3 class="title"><a title="<?php echo $groupbuy['groupbuy_name'];?>" href="<?php echo $groupbuy['groupbuy_url'];?>" target="_blank"><?php echo $groupbuy['groupbuy_name'];?></a></h3>
                        <?php list($integer_part, $decimal_part) = explode('.', $groupbuy['groupbuy_price']);?>
                        <div class="item-prices"> <span class="price"><i><?php echo $lang['currency'];?></i><?php echo $integer_part;?><em>.<?php echo $decimal_part;?></em></span>
                            <div class="dock"><span class="limit-num"><?php echo $groupbuy['groupbuy_rebate'];?>&nbsp;<?php echo $lang['text_zhe'];?></span> <del class="orig-price"><?php echo $lang['currency'].$groupbuy['goods_price'];?></del></div>
                            <span class="sold-num"><em><?php echo $groupbuy['buy_quantity']+$groupbuy['virtual_quantity'];?></em><?php echo $lang['text_piece'];?><?php echo $lang['text_buy'];?></span><a href="<?php echo $groupbuy['groupbuy_url'];?>" target="_blank" class="buy-button">我要团</a></div>
                    </div>
                </li>
                    <?php } ?>
                <?php } else { ?>
                    <div class="no-content"><?php echo $lang['no_groupbuy_info'];?></div>
                <?php } ?>
            </ul>
        </div>
    </div>
</div>
<script>
    (function($, wp, wps, window, undefined) {
    '$:nomunge';
    var $w = $(window),
    waypoints = [],
    oldScroll = -99999,
    didScroll = false,
    didResize = false,
    eventName = 'waypoint.reached',
    methods = {
        init: function(f, options) {
            this.each(function() {
                var $this = $(this),
                ndx = waypointIndex($this),
                base = ndx < 0 ? $.fn[wp].defaults: waypoints[ndx].options,
                opts = $.extend({},
                base, options);
                opts.offset = opts.offset === "bottom-in-view" ?
                function() {
                    return $[wps]('viewportHeight') - $(this).outerHeight();
                }: opts.offset;
                if (ndx < 0) {
                    waypoints.push({
                        element: $this,
                        offset: $this.offset().top,
                        options: opts
                    });
                }
                 else {
                    waypoints[ndx].options = opts;
                }
                f && $this.bind(eventName, f);
            });
            $[wps]('refresh');
            return this;
        },
        remove: function() {
            return this.each(function() {
                var ndx = waypointIndex($(this));
                if (ndx >= 0) {
                    waypoints.splice(ndx, 1);
                }
            });
        },
        destroy: function() {
            return this.unbind(eventName)[wp]('remove');
        }
    };
    function waypointIndex(el) {
        var i = waypoints.length - 1;
        while (i >= 0 && waypoints[i].element[0] !== el[0]) {
            i -= 1;
        }
        return i;
    }
    function triggerWaypoint(way, dir) {
        way.element.trigger(eventName, dir)
         if (way.options.triggerOnce) {
            way.element[wp]('destroy');
        }
    }
    function doScroll() {
        var newScroll = $w.scrollTop(),
        isDown = newScroll > oldScroll,
        pointsHit = $.grep(waypoints,
        function(el, i) {
            return isDown ? (el.offset > oldScroll && el.offset <= newScroll) : (el.offset <= oldScroll && el.offset > newScroll);
        });
        if (!oldScroll || !newScroll) {
            $[wps]('refresh');
        }
        oldScroll = newScroll;
        if (!pointsHit.length) return;
        if ($[wps].settings.continuous) {
            $.each(isDown ? pointsHit: pointsHit.reverse(),
            function(i, point) {
                triggerWaypoint(point, [isDown ? 'down': 'up']);
            });
        }
         else {
            triggerWaypoint(pointsHit[isDown ? pointsHit.length - 1: 0], [isDown ? 'down': 'up']);
        }
    }
    $.fn[wp] = function(method) {
        if (methods[method]) {
            return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        }
         else if (typeof method === "function" || !method) {
            return methods.init.apply(this, arguments);
        }
         else if (typeof method === "object") {
            return methods.init.apply(this, [null, method]);
        }
         else {
            $.error('Method ' + method + ' does not exist on jQuery' + wp);
        }
    };
    $.fn[wp].defaults = {
        offset: 0,
        triggerOnce: false
    };
    var jQMethods = {
        refresh: function() {
            $.each(waypoints,
            function(i, o) {
                var adjustment = 0,
                oldOffset = o.offset;
                if (typeof o.options.offset === "function") {
                    adjustment = o.options.offset.apply(o.element);
                }
                 else if (typeof o.options.offset === "string") {
                    var amount = parseFloat(o.options.offset),
                    adjustment = o.options.offset.indexOf("%") ? Math.ceil($[wps]('viewportHeight') * (amount / 100)) : amount;
                }
                 else {
                    adjustment = o.options.offset;
                }
                o.offset = o.element.offset().top - adjustment;
                if (oldScroll > oldOffset && oldScroll <= o.offset) {
                    triggerWaypoint(o, ['up']);
                }
                 else if (oldScroll < oldOffset && oldScroll >= o.offset) {
                    triggerWaypoint(o, ['down']);
                }
            });
            waypoints.sort(function(a, b) {
                return a.offset - b.offset;
            });
        },
        viewportHeight: function() {
            return (window.innerHeight ? window.innerHeight: $w.height());
        },
        aggregate: function() {
            var points = $();
            $.each(waypoints,
            function(i, e) {
                points = points.add(e.element);
            });
            return points;
        }
    };
    $[wps] = function(method) {
        if (jQMethods[method]) {
            return jQMethods[method].apply(this);
        }
         else {
            return jQMethods["aggregate"]();
        }
    };
    $[wps].settings = {
        continuous: true,
        resizeThrottle: 200,
        scrollThrottle: 100
    };
    $w.scroll(function() {
        if (!didScroll) {
            didScroll = true;
            window.setTimeout(function() {
                doScroll();
                didScroll = false;
            },
            $[wps].settings.scrollThrottle);
        }
    }).resize(function() {
        if (!didResize) {
            didResize = true;
            window.setTimeout(function() {
                $[wps]('refresh');
                didResize = false;
            },
            $[wps].settings.resizeThrottle);
        }
    }).load(function() {
        $[wps]('refresh');
        doScroll();
    });
})(jQuery, 'waypoint', 'waypoints', this);
</script>
<script language="JavaScript">
 //浮动导航  waypoints.js
$("#ncgCategory").waypoint(function(event, direction) {
    $(this).parent().toggleClass('sticky', direction === "down");
    event.stopPropagation();
});

//鼠标触及更替li样式
$(document).ready(function(){
    $("#list").hide();
    $("#button_show").click(function(){
        $("#list").toggle();
    });
    $("#button_close").click(function(){
        $("#list").hide();
    });
});

</script>